//
//  FirstChapterViewController.m
//  CoreAnimation
//
//  Created by 张国文 on 16/10/9.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "FirstChapterViewController.h"
#import "GuestImageViewController.h"
#import "CALayerDelegateViewController.h"
#import "DrawInContextViewController.h"
#import "CGImageCreateWithImageInRectViewController.h"
#import "SuperAndSuberViewViewController.h"

@interface FirstChapterViewController ()

@end

@implementation FirstChapterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    UIButton *firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
    firstButton.frame = CGRectMake(0, 20, 300, 50);
    [firstButton setTitle:@"寄宿图属性" forState:UIControlStateNormal];
    [firstButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    firstButton.tag = 100;
    [firstButton addTarget:self action:@selector(clickJump:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:firstButton];
    
    UIButton *sectionButton = [UIButton buttonWithType:UIButtonTypeCustom];
    sectionButton.frame = CGRectMake(0, 120, 300, 50);
    [sectionButton setTitle:@"drawLayerInContext" forState:UIControlStateNormal];
    [sectionButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    sectionButton.tag = 101;
    [sectionButton addTarget:self action:@selector(clickJump:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:sectionButton];
    
    UIButton *thirdButton = [UIButton buttonWithType:UIButtonTypeCustom];
    thirdButton.frame = CGRectMake(0, 220, 360, 50);
    [thirdButton setTitle:@"drawInContextAndCGContextSaveGState" forState:UIControlStateNormal];
    [thirdButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    thirdButton.tag = 102;
    [thirdButton addTarget:self action:@selector(clickJump:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:thirdButton];
    
    UIButton *fourButton = [UIButton buttonWithType:UIButtonTypeCustom];
    fourButton.frame = CGRectMake(0, 320, 300, 50);
    [fourButton setTitle:@"CGImageCreateWithImageInRect" forState:UIControlStateNormal];
    [fourButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    fourButton.tag = 103;
    [fourButton addTarget:self action:@selector(clickJump:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:fourButton];
    
    UIButton *fiveButton = [UIButton buttonWithType:UIButtonTypeCustom];
    fiveButton.frame = CGRectMake(0, 420, 300, 50);
    [fiveButton setTitle:@"父视图和子视图的关系" forState:UIControlStateNormal];
    [fiveButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    fiveButton.tag = 104;
    [fiveButton addTarget:self action:@selector(clickJump:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:fiveButton];
    
}

- (void)clickJump:(UIButton *)button
{
    switch (button.tag) {
        case 100:
        {
            GuestImageViewController *guestImageVC = [[GuestImageViewController alloc] init];
            [self.navigationController pushViewController:guestImageVC animated:YES];
            break;
        }
            case 101:
        {
            CALayerDelegateViewController *caLayerDelegateVC = [[CALayerDelegateViewController alloc] init];
            [self.navigationController pushViewController:caLayerDelegateVC animated:YES];
            break;
        }
            case 102:
        {
            DrawInContextViewController *drawInContextVC = [[DrawInContextViewController alloc] init];
            [self.navigationController pushViewController:drawInContextVC animated:YES];
            break;
        }
            case 103:
        {
            CGImageCreateWithImageInRectViewController *cgImageVC = [[CGImageCreateWithImageInRectViewController alloc] init];
            [self.navigationController pushViewController:cgImageVC animated:YES];
            break;
        }
            case 104:
        {
            SuperAndSuberViewViewController *superAndSuberViewVC = [[SuperAndSuberViewViewController alloc] init];
            [self.navigationController pushViewController:superAndSuberViewVC animated:YES];
        }
        default:
            break;
    }
}



@end
